import request from '@/utils/request'

//菜单管理相关的API请求函数
const BASE_URL = '/admin/system/sysMenu'

export default {

    //获取权限(菜单/功能)列表
    getMenuList() {
        return request({
            url: `${BASE_URL}/getMenuList`,
            method: 'get'
        }
        )
    },

    //添加新菜单
    addMenu(sysMenu) {
        return request({
            url: `${BASE_URL}/addMenu`,
            method: 'post',
            data: sysMenu
        });
    },

    //添加新菜单
    updateMenu(sysMenu) {
        return request({
            url: `${BASE_URL}/updateMenu`,
            method: 'post',
            data: sysMenu
        });
    },

    //删除菜单
    removeMenuById(id) {
        return request({
            url: `${BASE_URL}/removeMenuById/${id}`,
            method: 'delete'
        });
    },

    /*
    查看某个角色的权限列表
    */
    toAssign(roleId) {
        return request({
            url: `${BASE_URL}/toAssign/${roleId}`,
            method: 'get'
        })
    },

    /*
    给某个角色授权
    */
    doAssign(assginMenuVo) {
        return request({
            url: `${BASE_URL}/doAssign`,
            method: "post",
            data: assginMenuVo
        })
    }
}